<!-- 
	装修页：动态组件
	注：小程序暂不支持动态组件写法
	props:
		datas: 接口下发的组件数据
	
	action:
		getComponent:根据组件id获取对应组件 枚举说明：./type/componentType.js
-->
<template>
    <view>
        <scroll-view :style="{ height: listHeight }" scroll-y @scrolltolower="scrolltolower" lower-threshold="30"
            class="dy-index">
            <!-- 小程序暂不支持动态组件写法 -->
            <!-- <component
			v-for="(item,index) in datas" 
			:is="getComponent(item.id)" 
			:data="item" 
			:key="index"
			@searchFn="searchFn"
			@goSearch="goSearch"
		></component> -->
            <view class="tabs" v-if="tabsData.length > 0" :style="{ background: getThemeColor }">
                <view class="tabList">
                    <view v-for="(item, index) in tabsData" :class="tabsActive == index ? 'active' : ''"
                        @click="selAppIndex(item)">{{ item.Name }}</view>
                </view>
            </view>
            <view v-for="(item, index) in widgets" :key="index">
                <dynamic-search-bar v-if="item.Widget == 'widget-search' && item.isShow" :data="item.Setting"
                    @searchFn="searchFn" @goSearch="goSearch" @loadBack="loadBack" @clickLeftFn="clickLeftFn"
                    @areaSelectFn="areaSelectFn" @warehouseListFn="warehouseListFn" @clickRightFn="clickRightFn"
                    @goTo="goTo" :streetName="streetName" :WarehouseName="WarehouseName"
                    :isMixSearchBanner="isMixSearchBanner"></dynamic-search-bar>
                <dynamic-banner v-if="item.Widget == 'widget-banner' && item.isShow" :data="item.Setting"
                    @bannerClick="bannerClick" @loadBack="loadBack"
                    :isMixSearchBanner="isMixSearchBanner"></dynamic-banner>
                <dynamic-editor v-if="item.Widget == 'widget-editor' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack" @mixSearchBanner="mixSearchBanner"></dynamic-editor>
                <dynamic-notice v-if="item.Widget == 'widget-notice' && item.isShow" :data="item.Setting"
                    @noticeClick="noticeClick" @loadBack="loadBack"
                    :isMixSearchBanner="isMixSearchBanner"></dynamic-notice>
                <dynamic-space v-if="item.Widget == 'widget-space' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-space>
                <dynamic-title v-if="item.Widget == 'widget-title' && item.isShow" :data="item.Setting"
                    @titleClick="titleClick" @loadBack="loadBack"></dynamic-title>
                <dynamic-menu v-if="item.Widget == 'widget-menulist' && item.isShow" :data="item.Setting"
                    @menuClick="menuClick" @loadBack="loadBack" :isMixSearchBanner="isMixSearchBanner"></dynamic-menu>
                <dynamic-goods-list v-if="item.Widget == 'widget-goodslist' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack" @buyFn="buyFn" ref="dynamicGoodsList"></dynamic-goods-list>
                <dynamic-goodslistgroup v-if="item.Widget == 'widget-goodslistgroup' && item.isShow"
                    :data="item.Setting" @loadBack="loadBack" @buyFn="buyFn"
                    ref="dynamicGoodsList"></dynamic-goodslistgroup>
                <dynamic-ad-list v-if="item.Widget == 'widget-adlist' && item.isShow" :data="item.Setting"
                    @adClick="adClick" @loadBack="loadBack"></dynamic-ad-list>
                <dynamic-text v-if="item.Widget == 'widget-text' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-text>
                <dynamic-line v-if="item.Widget == 'widget-line' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-line>
                <dynamic-supplier-list v-if="item.Widget == 'widget-supplierlist' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack" ref="dynamicSupplierList"></dynamic-supplier-list>
                <dynamic-goods-category v-if="item.Widget == 'goods-category3' && false" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-goods-category>
                <dynamic-category v-if="item.Widget == 'widget-category' && false" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-category>
                <dynamic-seckill v-if="item.Widget == 'widget-seckillgoodslist' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-seckill>
                <dynamic-couponBuy v-if="item.Widget == 'widget-couponHuan' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-couponBuy>
                <dynamic-video v-if="item.Widget == 'widget-video' && item.isShow" :data="item.Setting"
                    @loadBack="loadBack"></dynamic-video>
            </view>
            <!--#ifdef APP-->
            <view class="bei-an" v-if="webInfo.AppIcpNo">{{ webInfo.AppIcpNo }}</view>
            <!--#endif-->
            <!--#ifndef APP-->
            <view class="bei-an" v-if="webInfo.MiniAppIcpNo">{{ webInfo.MiniAppIcpNo }}</view>
            <!--#endif-->
        </scroll-view>
        <!-- 弹窗移到scroll-view外，解决iphonex 下弹窗被tab挡住 -->
        <uni-popup type="bottom" ref="popSku" @change="skuChange" v-if="!getAppSet().pagesClassify">
            <product-spec v-if="showPopSku" :data="optPopup.data" :fresh="optPopup.change" :popup-type="optPopup.type"
                :skuImg="optPopup.skuImg" @closePopup="closePopup" @addCart="addCart" @addBatch="addBatch"
                @setCarListFunc="setCarListFunc" @specTreeClickEvent="specTreeClickEvent">
            </product-spec>
        </uni-popup>
        <uni-popup type="bottom" ref="popSku" @change="skuChange" v-else>
            <product-class-spec v-if="showPopSku" :data="optPopup.data" :fresh="optPopup.change"
                :popup-type="optPopup.type" @changeProductData="changeProductData" @closePopup="closePopup"
                @addCart="addCart" @addBatch="addBatch" @setCarListFunc="setCarListFunc">
            </product-class-spec>
        </uni-popup>
        <uni-popup ref="areaSelect" type="bottom" background-color="#fff" :safe-area="false">
            <view class="area-title">
                <view class="close" @click="close">取消</view>
                <view class="title">选择地址</view>
                <view class="colormain" @click="affirm">确认</view>
            </view>
            <view class="locationmian">
                <view class="btn-location">
                    <dynamic-iconsfont size="32" color="#333" customIcons="icon-dizhi1"></dynamic-iconsfont>
                    <view>{{ data.StreetName }}</view>
                </view>
                <view class="anew" @click="getLoaction">
                    <image src="@/static/img/qiehuan.png"></image>
                    <view>定位当前</view>
                </view>
            </view>

            <area-select :address-data="data" @pickArea="pickArea" :location="1"></area-select>
        </uni-popup>
        <uni-popup ref="WarehouseTip" type="center" :animation="false" :mask-click="false">
            <view class="Warehouselist">
                <view class="pop-return-title">
                    <text>选择仓库</text>
                </view>
                <search-bar :placeholderText="placeholderText" :searchValue="searchKey"
                    @searchFn="searchFnWarehouse"></search-bar>
                <scroll-view class="scroll-box" :scroll-y="true" :show-scrollbar="false">
                    <view class="w-list">
                        <view v-for="item in warehouseListdata" @click="selectWarehouse(item)">{{
                            item.WarehouseName
                        }}</view>
                    </view>
                </scroll-view>
                <image src="@/static/img/close_one.png" class="closeimg" @click="closePop"></image>
            </view>
        </uni-popup>
        <view class="adver" v-if="advShow">
            <view>
                <image :src="easyGetImgUrl(advertisingData.Imgurl)" @click="advGo()" class="advimage" mode="widthFix">
                </image>
                <image src="@/static/img/close_one.png" class="closeimg" @click="closeAdv"></image>
            </view>
        </view>
        <view class="cap-contact-us" @click="reset()" v-if="getAppSet().homeRefresh">
            <image src="https://oss.hsy884.com//upload/2020/05/31/20200531180944538.png" />
        </view>
    </view>
</template>

<script>
import { mapGetters } from "vuex"
import searchBar from "@/components/common/search-bar.vue"
import storage from "@/uni-sub-base/utils/storage.js"
import { getElementHeight } from "@/uni-sub-base/utils/elementUtil.js"
import { GetUserRegion, UpdateUserRegion, batchSmartParse, deleteUserCar } from "@/service/api/member.js"
import { GetAppActivePage } from "@/service/api/coupon.js"
import { GetWarehouseList } from "@/service/api/warehouse.js"
import { GetTabPageTemplateList } from "@/service/api/pageTemplate.js"
import dynamicIconsfont from "@/uni-sub-base/components/dynamic/dynamic-iconsfont.vue"
import areaSelect from "@/uni-sub-base/components/area-select/area-select.vue"
import DynamicSearchBar from "@/uni-sub-base/components/dynamic/dynamic-search-bar.vue"
import DynamicBanner from "@/uni-sub-base/components/dynamic/dynamic-banner.vue"
import DynamicNotice from "@/uni-sub-base/components/dynamic/dynamic-notice.vue"
import DynamicSpace from "@/uni-sub-base/components/dynamic/dynamic-space.vue"
import DynamicTitle from "@/uni-sub-base/components/dynamic/dynamic-title.vue"
import DynamicMenu from "@/uni-sub-base/components/dynamic/dynamic-menu.vue"
import dynamicGoodsList from "@/uni-sub-base/components/dynamic/dynamic-goods-list.vue"
import dynamicGoodslistgroup from "@/uni-sub-base/components/dynamic/dynamic-goodslistgroup.vue"
import dynamicGoodsCategory from "@/uni-sub-base/components/dynamic/dynamic-goods-category.vue"
import dynamicEditor from "@/uni-sub-base/components/dynamic/dynamic-editor.vue"
import dynamicAdList from "@/uni-sub-base/components/dynamic/dynamic-ad-list.vue"
import dynamicText from "@/uni-sub-base/components/dynamic/dynamic-text.vue"
import dynamicLine from "@/uni-sub-base/components/dynamic/dynamic-line.vue"
import dynamicCategory from "@/uni-sub-base/components/dynamic/dynamic-category.vue"
import dynamicSeckill from "@/uni-sub-base/components/dynamic/dynamic-seckill.vue"
import dynamicSupplierList from "@/uni-sub-base/components/dynamic/dynamic-supplier-list.vue"
import dynamicCouponBuy from "@/uni-sub-base/components/dynamic/dynamic-couponBuy.vue"
import dynamicVideo from "@/uni-sub-base/components/dynamic/dynamic-video.vue"
import productSpec from "@/components/product/product-spec.vue"
import productClassSpec from "@/components/productClass/product-spec.vue"
import { getLocation } from "@/uni-sub-base/utils/mapUtil.js"
import { getUserInfo, getProductDisplay } from "@/utils/appInit.js"
export default {
    components: {
        searchBar,
        dynamicIconsfont,
        areaSelect,
        productSpec,
        productClassSpec,
        "dynamic-search-bar": DynamicSearchBar,
        "dynamic-banner": DynamicBanner,
        "dynamic-notice": DynamicNotice,
        "dynamic-space": DynamicSpace,
        "dynamic-title": DynamicTitle,
        "dynamic-menu": DynamicMenu,
        "dynamic-goods-list": dynamicGoodsList,
        "dynamic-goodslistgroup": dynamicGoodslistgroup,
        "dynamic-goods-category": dynamicGoodsCategory,
        "dynamic-editor": dynamicEditor,
        "dynamic-ad-list": dynamicAdList,
        "dynamic-text": dynamicText,
        "dynamic-line": dynamicLine,
        "dynamic-category": dynamicCategory,
        "dynamic-seckill": dynamicSeckill,
        "dynamic-supplier-list": dynamicSupplierList,
        "dynamic-couponBuy": dynamicCouponBuy,
        "dynamic-video": dynamicVideo,

    },
    props: {
        listHeight: {
            type: String,
            default: "500px",
        },
        datas: {
            type: Array,
            default: () => [],
        },
        BackGroundColor: {
            type: String,
            default: "",
        },
    },
    computed: {
        ...mapGetters(["getWareView"]),
    },
    watch: {
        datas(e) {
            this.widgets = e
        },
        getWareView(e) {
            let warehouse = storage.getCache("warehouse")
            this.WarehouseName = warehouse.WarehouseName
        },
    },
    data() {
        return {
            widgets: [],
            loadOk: false,
            h5BasePath: "/pages/web/h5?url=",
            showPopSku: false,
            // sku 商品规格弹窗
            optPopup: {
                data: {},
                type: "",
                change: false,
                show: true,
                skuImg: "",
            },
            isMixSearchBanner: false,
            data: {
                AddressName: "",
                ContactName: "",
                ContactTel: "",
                ContactAddress: "",
                ProvinceId: 0,
                ProvinceName: "",
                CityId: 0,
                CityName: "",
                AreaId: 0,
                AreaName: "",
                StreetId: 0,
                StreetName: "",
            },
            streetName: "",
            areadata: {},
            regionName: "",
            warehouseListdata: [],
            searchKey: "",
            placeholderText: "请输入仓库名称",
            WarehouseName: "",
            tabsData: [],
            tabsActive: 0,
            advertisingData: {},
            advShow: false,
            webInfo: {}
        }
    },
    mounted() {
        this.datas.forEach((e, index) => {
            e.Setting.index = index
            if (index == 0) {
                e.isShow = true
            }
        })
        this.widgets = this.datas
        this.getRegion()
        let webInfo = storage.getCache("webInfo")
        this.webInfo = webInfo
        if (webInfo.IsSelectWarehouse == 1) {
            this.warehouseList()
        }
        this.GetTabPageTemplate()
        setTimeout((e) => {
            let token = storage.getCache("token")
            if (token) {
                this.activePage()
            }
        }, 1000)
    },
    methods: {
        changeProductData(product) {
            this.optPopup.data = product
            this.optPopup.change = true
        },
        activePage() {
            let path = "?pageId=0"
            let AppIndexID = storage.getCache("AppIndexID")
            if (AppIndexID) {
                path = "?pageId=" + AppIndexID
            }
            GetAppActivePage(path).then((res) => {
                if (res.State == 1) {
                    this.advertisingData = res.Data
                    if (this.advertisingData && this.advertisingData.Imgurl) {
                        this.advShow = true
                    }
                } else {
                    // this.easyToast(res.Msg)
                }
                this.$nextTick(e => {
                    storage.removeCache("AppIndexID")
                })
                // setTimeout((e) => {
                // }, 1500)
            })
        },
        advGo() {
            if (this.advertisingData.AppJumpLink == "takeCoupon") {
                this.easyGoTo("/pages_scan/packet/go/coupon")
            } else if (this.advertisingData.AppJumpLink == "product") {
                this.$nextTick(() => {
                    this.easyGoProduct()
                })
            } else {
                this.easyGoTo(this.advertisingData.AppJumpLink)
            }
            this.closeAdv()
        },
        closeAdv() {
            this.advShow = false
        },
        GetTabPageTemplate() {
            let path = `?pageType=4`
            GetTabPageTemplateList(path).then((res) => {
                if (res.State == 1) {
                    this.tabsData = res.Data
                    let AppShowData = storage.getCache("AppShowData")
                    this.tabsData.forEach((item, index) => {
                        if (AppShowData) {
                            if (AppShowData.ID == item.ID) {
                                this.tabsActive = index
                                // setTimeout((e) => {
                                // 	storage.removeCache("AppShowData")
                                // }, 1500)
                                this.$nextTick(e => {
                                    storage.removeCache("AppShowData")
                                })
                                return
                            }
                        } else {
                            if (item.HomePage == 1) {
                                this.tabsActive = index
                                return
                            }
                        }
                    })
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
        selAppIndex(item) {
            storage.setCache("AppShowData", item)
            storage.setCache("AppIndexID", item.ID)
            uni.reLaunch({
                url: "/pages/index/index",
            })
        },
        getLoaction() {
            getLocation(
                (res) => {
                    if (res) {
                        this.data.ContactAddress = res.address.street + res.address.streetNum
                        this.getP(res.address, res.regeocodeData)
                    }
                },
                (err) => {
                    console.log(err)
                },
            )
        },
        getP(res, res1) {
            let item = {
                ContactAddress: res.street + res.streetNum,
                ProvinceName: res.province,
                CityName: res.city,
                AreaName: res.district,
                StreetName: res1.addressComponent.township,
                ContactName: this.data.ContactName || "aaa",
                ContactTel: this.data.ContactTel || "13300000000",
            }
            let list = []
            list.push(item)
            let param = {
                list: list,
            }
            this.batchSmartParse(param)
        },
        //智能识别
        batchSmartParse(param) {
            batchSmartParse(param).then((res) => {
                if (res.Data && res.Data.list && res.Data.list.length > 0) {
                    let result = res.Data.list[0]
                    this.areadata.ProvinceId = result.ProvinceId
                    this.areadata.ProvinceName = result.ProvinceName
                    this.areadata.CityId = result.CityId
                    this.areadata.CityName = result.CityName
                    this.areadata.AreaId = result.AreaId
                    this.areadata.AreaName = result.AreaName
                    this.areadata.StreetId = result.StreetId
                    this.areadata.StreetName = result.StreetName
                    this.data.ProvinceId = result.ProvinceId
                    this.data.ProvinceName = result.ProvinceName
                    this.data.CityId = result.CityId
                    this.data.CityName = result.CityName
                    this.data.AreaId = result.AreaId
                    this.data.AreaName = result.AreaName
                    this.data.StreetId = result.StreetId
                    this.data.StreetName = result.StreetName
                }
            })
        },
        getRegion() {
            let token = storage.getCache("token")
            if (token) {
                GetUserRegion().then((res) => {
                    if (res.State == 1) {
                        this.data = res.Data
                        this.data.AreaId = res.Data.RegionId
                        this.data.AreaName = res.Data.RegionName
                        this.streetName = res.Data.StreetName
                    } else {
                        this.easyToast(res.Msg)
                    }
                })
            }
        },
        warehouseListFn() {
            this.$refs.WarehouseTip.open()
        },
        closePop() {
            this.$refs.WarehouseTip.close()
        },
        warehouseList() {
            let path = "?searchKey=" + this.searchKey
            GetWarehouseList(path).then((res) => {
                if (res.State == 1) {
                    this.warehouseListdata = res.Data.reverse();
                    let warehouse = storage.getCache("warehouse")
                    if (warehouse) {
                        let warehouseData = res.Data.filter((item) => {
                            return item.WarehouseName == warehouse.WarehouseName
                        })
                        if (warehouseData.length > 0) {
                            this.WarehouseName = warehouse.WarehouseName
                        } else {
                            this.WarehouseName = res.Data[0].WarehouseName
                            storage.setCache("warehouse", res.Data[0])
                        }
                    } else {
                        this.WarehouseName = res.Data[0].WarehouseName
                        storage.setCache("warehouse", res.Data[0])
                    }
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
        selectWarehouse(item) {
            storage.setCache("warehouse", item)
            this.closePop()
            uni.reLaunch({
                url: "/pages/login/loading",
            })
        },
        //搜索
        searchFnWarehouse(searchKey) {
            this.searchKey = searchKey
            this.warehouseListdata = []
            this.warehouseList()
        },
        //选择地区
        areaSelectFn() {
            this.getRegion()
            this.$refs.areaSelect.open()
        },
        //选择地区回调
        pickArea(data) {
            this.areadata = data
        },
        close() {
            this.$refs.areaSelect.close()
        },
        affirm() {
            if (!this.areadata.ProvinceId) {
                this.areadata = this.data
            }
            let param = {
                provinceName: this.areadata.ProvinceName,
                cityName: this.areadata.CityName,
                regionName: this.areadata.AreaName,
                streetName: this.areadata.StreetName,
                provinceId: this.areadata.ProvinceId,
                cityId: this.areadata.CityId,
                regionId: this.areadata.AreaId,
                streetId: this.areadata.StreetId,
            }
            UpdateUserRegion(param).then((res) => {
                if (res.State == 1) {
                    this.close()
                    this.deleteCar()
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
        deleteCar() {
            let param = {
                ids: "",
            }
            deleteUserCar(param).then((res) => {
                if (res) {
                    uni.reLaunch({
                        url: "/pages/login/loading",
                    })
                }
            })
        },
        getUserInfo() {
            let url = "/pages/index/index"
            getUserInfo().then((res) => {
                uni.hideLoading()
                uni.reLaunch({
                    url: url,
                })
            })
        },
        //搜索栏左按钮点击
        clickLeftFn() {
            //目前先固定是进入商品分类，后面动态设置
            // this.easyGoTo("/pages/product/index")
            this.easyGoTo("/pages_shop/packet/product/productClass")
        },
        //搜索栏右按钮点击
        clickRightFn() {
            //目前先固定是客服热线，后面动态设置
            let webInfo = storage.getCache("webInfo")
            if (webInfo && webInfo.ServiceTel) {
                uni.makePhoneCall({
                    phoneNumber: webInfo.ServiceTel,
                })
            }
        },
        //是否开启混合组件
        mixSearchBanner(e) {
            if (e) {
                this.isMixSearchBanner = true
            }
        },
        //获取对应组件
        getComponent(id) {
            return "dynamic-search-bar"
        },
        //搜索回调
        searchFn(key) { },
        //去搜索
        goSearch() {
            if (this.getSupplierMode() == 0) {
                this.easyGoTo("/pages_shop/packet/search/index")
            } else if (this.getSupplierMode() == 1) {
                this.easyGoTo("/pages_supplier/packet/search/index")
            }
        },
        //点击公告
        noticeClick(item) {
            this.easyGoTo("/pages_me/packet/message/newsDetails?id=" + item.ID)
        },
        //点击标题
        titleClick(item) {
            this.clickFn(item)
        },
        //点击轮播图
        bannerClick(item) {
            this.clickFn(item)
        },
        //点击广告图
        adClick(item) {
            this.clickFn(item)
        },
        menuClick(item) {
            this.clickFn(item)
        },
        goTo(item) {
            let token = storage.getCache("token")
            if (!token || token == "") {
                this.$showModal({ show: true })
                return false
            }
            if (item.includes("AppIndex")) {
                //进入其他装修页
                let spliceLength2 = item.lastIndexOf("/")
                let AppIndexID = item.slice(spliceLength2 + 1)
                let obj = {
                    ID: AppIndexID
                }
                storage.setCache("AppShowData", obj)
                storage.setCache("AppIndexID", AppIndexID)
                uni.reLaunch({
                    url: "/pages/index/index",
                })
            } else {
                this.easyGoTo(item)
            }
        },
        clickFn(item) {
            if (item.Type == "user-center'") {
                //个人中心
                this.easyGoTo("/pages/me/index")
            } else if (item.Type == "product-list'") {
                //商品列表
                this.easyGoProduct()
            } else if (item.Type == "order-list'") {
                //订单列表
                this.easyGoTo("/pages/order/index")
            } else if (item.Type == "shopping-cart'") {
                //购物车
                this.easyGoTo("/pages/cart/index")
            } else if (item.Type == "mini-program" || item.Type == "applets") {
                let path = item.Miniurl
                let id = item.Appmini
                let appid = item.Appid
                this.openMiniProgram(path, id, appid)
            } else if (item.Type == "app" || item.Type == "mini-app") {
                this.jumpApp(item.AppidApp, item.AppminiApp, item.MiniurlApp)
            }
            if (!item || !item.Value) {
                return
            }
            if (item.Type == "custom") {
                //自定义跳转
                if (item.Value.includes("http")) {
                    //进入网页
                    this.easyGoTo(this.getH5Url(item.Value))
                } else if (item.Value.includes("AppIndex")) {
                    //进入网页
                    let spliceLength2 = item.Value.lastIndexOf("/")
                    let AppIndexID = item.Value.slice(spliceLength2 + 1)
                    let obj = {
                        ID: AppIndexID
                    }
                    storage.setCache("AppShowData", obj)
                    storage.setCache("AppIndexID", AppIndexID)
                    uni.reLaunch({
                        url: "/pages/index/index",
                    })
                } else {
                    if (item.Value.includes("tabindex")) {
                        //商品列表常购 收藏 促销
                        let spliceLength2 = item.Value.lastIndexOf("/")
                        let tabindexID = item.Value.slice(spliceLength2 + 1)
                        storage.setCache("tabindexID", tabindexID)
                    }
                    //原生路由页面
                    this.easyGoTo(item.Value)
                }
            } else if (item.Type == "product-category") {
                //商品分类
                if (this.getAppSet().pagesClassify) {
                    this.easyGoTo("/pages_classify/packet/product/productClass?classid=" + item.Value)
                } else {
                    let classifyID = item.Value
                    storage.setCache("classifyID", classifyID)
                    this.$nextTick(() => {
                        this.easyGoProduct()
                    })
                    // this.easyGoTo("/pages_shop/packet/product/productClass?typeId=" + item.Value)
                }
                // storage.setCache('productClassify', item.Value)
                // this.$nextTick(()=>{
                // 	this.easyGoProduct()
                // })
            } else if (item.Type == "product-tagid") {
                //商品标签
                let tagId = item.Value.replace("sid:", "")
                storage.setCache("productTagId", tagId)
                this.$nextTick(() => {
                    this.easyGoProduct()
                })
            } else if (item.Type == "product-brandid") {
                //商品品牌
                let brandId = item.Value.replace("ndid:", "")
                storage.setCache("productBrandId", brandId)
                this.$nextTick(() => {
                    this.easyGoProduct()
                })
            } else if (item.Type == "product-item") {
                if (this.getAppSet().pagesClassify) {
                    this.easyGoTo("/pages_classify/packet/product/productDetail?id=" + item.Value + "&InfoType=0")
                } else {
                    this.easyGoTo("/pages_shop/packet/product/productDetail?id=" + item.Value + "&InfoType=0")
                }
            } else if (item.Type == "product-line") {
                // 产品线
                let ProductLineIds = item.Value.replace("eid:", "")
                // storage.setCache("ProductLineIds", ProductLineIds)
                this.easyGoTo("/pages_classify/packet/product/productClass?ProductLineIds=" + ProductLineIds)
            }

        },
        jumpApp(AppidApp, AppminiApp, MiniurlApp) {//AppidApp 安卓包名,AppminiApp苹果下载地址,MiniurlApp 苹果URLscheme
            let that = this
            if (plus.os.name == 'Android') {
                plus.runtime.launchApplication(
                    {
                        // pname: 'com.hct.shop'  
                        pname: AppidApp
                    },
                    function (e) {
                        let appurl = "market://details?id=" + AppidApp //这个是通用应用市场，如果想指定某个应用商店，需要单独查这个应用商店的包名或scheme及参数
                        plus.runtime.openURL(appurl)
                    }
                );
            } else if (plus.os.name == 'iOS') {
                plus.runtime.launchApplication({ action: MiniurlApp }, function (e) {
                    let appurl = AppminiApp;
                    // let appurl = "itms-apps://itunes.apple.com/cn/app/hello-uni-app/id1417078253?mt=8"; 
                    plus.runtime.openURL(appurl, function (res) {
                        console.log(res);
                    });
                });
            }
        },
        getH5Url(url) {
            return this.h5BasePath + url
        },
        loadBack(index) {
            this.datas.forEach((e) => {
                if (e.Setting.index == index + 1) {
                    e.isShow = true
                }
            })
            this.$forceUpdate()
        },
        //滚动到底监听
        scrolltolower(e) {
            //遍历所有列表组件，内部判断是否要加载更多
            if (this.$refs.dynamicGoodsList) {
                this.$refs.dynamicGoodsList.forEach((e) => {
                    e.listGetMoreData()
                })
            }
            if (this.$refs.dynamicSupplierList) {
                this.$refs.dynamicSupplierList.forEach((e) => {
                    e.listGetMoreData()
                })
            }
            if (this.$refs.dynamicGoodslistgroup) {
                this.$refs.dynamicGoodslistgroup.forEach((e) => {
                    e.listGetMoreData()
                })
            }
        },
        buyFn(item) {
            this.showPopSku = false
            this.$nextTick(() => {
                this.showPopSku = true
                this.optPopup.type = "attr"
                this.optPopup.data = item
                // 默认选中第一个规格，显示对应规格图片
                let ProductSkuAttrList = item?.ProductSkuAttrList;
                let SkuId = "";
                if (ProductSkuAttrList && ProductSkuAttrList.length) {
                    let ProductAttrList = ProductSkuAttrList[0].ProductAttrList;
                    if (ProductAttrList && ProductAttrList.length) {
                        ProductAttrList.forEach((pItem, index) => {
                            if (index == 0) {
                                SkuId = pItem.SkuModel.SkuId
                                this.optPopup.skuImg = pItem.SkuModel.SkuImg
                            }
                        })
                    }
                }
                this.$refs.popSku.open()
            })
        },
        skuChange() { },
        closePopup() {
            this.showPopSku = false
            this.$refs.popSku.close()
        },
        setCarListFunc() {
            this.$forceUpdate()
        },
        specTreeClickEvent(item, index) {
            let skuId = "";
            // 找到对应品名skuid
            if (item.ProductAttrList && item.ProductAttrList.length > 0) {
                item.ProductAttrList.forEach((e, index) => {
                    if (index == 0) {
                        skuId = e.SkuId
                        this.optPopup.skuImg = e.SkuImg = e.SkuModel.SkuImg
                    }

                })
            }
        },
        closePopupBatch() {
            this.$refs.popBatch.close()
        },
        setCarListFuncBatch() {
            this.$forceUpdate()
        },
        addCart() {
            this.closePopup()
        },
        addBatch() {
            this.closePopup()
        },
        reset() {
            uni.reLaunch({
                url: "/pages/login/loading",
            })
        },
    },
}
</script>

<style lang="scss" scope>
.area-title {
    display: flex;
    justify-content: space-between;
    padding: 24rpx;

    .title {
        font-weight: bold;
    }
}

.close {
    color: #999;
}

.colormain {
    color: $app-color-main;
}

.btn-location {
    display: flex;
    align-items: center;
    font-size: 30rpx;
    font-weight: bold;
    color: #333333;
}

.locationmian {
    display: flex;
    padding: 24rpx 42rpx 0rpx 42rpx;
    align-items: center;
    justify-content: space-between;

    .anew {
        display: flex;
        align-items: center;
        color: #0091ff;
        font-size: 26rpx;
    }

    image {
        width: 40rpx;
        height: 40rpx;
    }
}

.Warehouselist {
    background: $color-white;
    border-radius: 20rpx;
    width: 600rpx;
    position: relative;

    .pop-return-title {
        display: flex;
        justify-content: center;
        padding: $app-page-padding 0 0 0;

        text {
            font-size: 34rpx;
        }
    }

    .closeimg {
        width: 64rpx;
        height: 64rpx;
        position: absolute;
        bottom: -96rpx;
        left: 50%;
        margin-left: -32rpx;
    }

    .scroll-box {
        max-height: 40vh;
    }

    .w-list {
        padding: 0 $app-page-padding $app-page-padding $app-page-padding;

        view {
            font-size: 28rpx;
            padding: $app-item-padding 0;
            border-bottom: 1rpx solid #ebebeb;
        }
    }
}

.tabs {
    display: flex;
    justify-content: center;
    padding: 12rpx 0;
}

.tabList {
    display: flex;
    overflow-x: scroll;
    height: 50rpx;
    border-radius: 30rpx;
    background: rgba(255, 255, 255, 0.6);
    align-items: center;
    justify-content: flex-start;
    font-size: 24rpx;
    color: #333;

    view {
        padding: 0 22rpx;
        // background: red;
        flex-flow: 0;
        flex-shrink: 0;
        height: 50rpx;
        line-height: 50rpx;
        border-radius: 24rpx;
    }

    view.active {
        background: rgba(255, 255, 255, 0.69);
        font-weight: bold;
    }
}

.adver {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;

    view {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
        flex-direction: column;
    }

    .advimage {
        width: 560rpx;
        border-radius: 10rpx;
    }

    .closeimg {
        width: 64rpx;
        height: 64rpx;
        margin-top: 40rpx;
    }
}

.cap-contact-us {
    position: fixed;
    z-index: 9;
    border-radius: 50%;
    width: 64rpx;
    height: 64rpx;
    background: rgba(0, 0, 0, 0.5);
    right: 24rpx;
    bottom: 140rpx;

    image {
        width: 64rpx;
        height: 64rpx;
    }
}
</style>
